package cn.ac.sec.oil.data_analysis.protocol;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.Scanner;

public class FileOperate {
	
	public String FileToStr(String filePath,String encoding) {
		
		String fileStr = null;
		
        try {
			InputStream inputStream = new FileInputStream(filePath);
			Scanner scanner = new Scanner(inputStream, encoding);
			fileStr = scanner.useDelimiter("\\A").next();
			
			scanner.close();			
		} catch (FileNotFoundException e) {
			
			System.out.println("FileToStr: file does not exist.");
		}        
        return fileStr;
    }
	
}